/* 统一响应返回客户端机制 */
export default (req, res, next) => {
  /* 统一的返回客户端结果方法模块 */
  const responseData = {
    code: 200,
    message: '',
    data: null,
  }
  res.sendResult = (data, message, code = responseData.code) => {
    responseData.code = code
    responseData.message = message
    responseData.data = data
    res.json(responseData)
  }
  next()
}
